package com.heu.blood.examine.controller;

import com.heu.blood.common.aop.ControllerLogAnnotation;
import com.heu.blood.common.utils.PageUtils;
import com.heu.blood.common.utils.R;
import com.heu.blood.examine.entity.OperateExamineEntity;
import com.heu.blood.examine.service.OperateExamineService;
import com.heu.blood.examine.vo.OperateExamineSelectVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;




/**
 * 
 *
 * @author lyj
 * @email lyj@heu.com
 * @date 2024-08-20 19:04:02
 */
@RestController
@RequestMapping("examine/operateexamine")
public class OperateExamineController {
    @Autowired
    private OperateExamineService operateExamineService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestBody OperateExamineSelectVo selectVo){
        PageUtils page = operateExamineService.queryPage(selectVo);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		OperateExamineEntity operateExamine = operateExamineService.getById(id);

        return R.ok().put("operateExamine", operateExamine);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody OperateExamineEntity operateExamine){
		operateExamineService.save(operateExamine);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody OperateExamineEntity operateExamine){
		operateExamineService.updateById(operateExamine);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		operateExamineService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    /**
     * 确认审核
     */
    @RequestMapping("/sureExamine")
    public R sureExamine(@RequestBody OperateExamineEntity operateExamine){
        int flag = operateExamineService.sureExamine(operateExamine);
        return R.ok();
    }

    /**
     * 确认拒绝并给出理由
     */
    @RequestMapping("/rejectExamine")
    public R rejectExamine(@RequestBody OperateExamineEntity operateExamine){
        int flag = operateExamineService.rejectExamine(operateExamine);
        return R.ok();
    }
    /**
     * 新增一条审批记录
     */
    @RequestMapping("/addOne")
    public R addOne(@RequestBody OperateExamineEntity operateExamine){
        int flag = operateExamineService.addOne(operateExamine);

        return R.ok();
    }

    /**
     * 查看审批的业务的详情
     */
    @RequestMapping("/info")
    @ControllerLogAnnotation(module = "审批模块", operate = "根据applicationId查看审批的业务的详情")
    public R info(@RequestBody OperateExamineEntity operateExamineEntity){
        Object res = operateExamineService.info(operateExamineEntity);
        return R.ok().put("data",res);
    }

    /**
     * 删除某条审批记录
     */
    @RequestMapping("/deleteExamine")
    @ControllerLogAnnotation(module = "审批模块", operate = "删除某条审批记录")
    public R deleteExamine(@RequestBody OperateExamineEntity operateExamineEntity){
        int flag = operateExamineService.deleteExamine(operateExamineEntity);
        return R.ok();
    }


}
